﻿using System;
using System.Windows;

namespace Gmantis.Controls
{
    public class MenuList : Menu
    {
        // Methods
        public MenuList()
        {
            base.DefaultStyleKey = typeof(MenuList);
        }

        internal override void CloseMenu()
        {
            base.CloseMenu();
            DropDownButton parent = base.Parent as DropDownButton;
            if (parent != null)
            {
                parent.IsDropDownOpen = false;
            }
        }

        protected override void PrepareContainerForItemOverride(DependencyObject element, object item)
        {
            base.PrepareContainerForItemOverride(element, item);
            MenuItem item2 = element as MenuItem;
            if (item2 != null)
            {
                item2.MenuBehavior = new ContextMenuItemBehavior(item2);
            }
        }

        internal override void UpdateAutoCloseAreas()
        {
            DropDownButton parent = base.Parent as DropDownButton;
            if ((parent == null) || parent.IsDropDownOpen)
            {
                base.UpdateAutoCloseAreas();
            }
        }
    }
}
